home *** CD-ROM | disk | FTP | other *** search
/ s-gikan2.maizuru-ct.ac.jp / s-gikan2.maizuru-ct.ac.jp.zip / s-gikan2.maizuru-ct.ac.jp / pub / ncvc352a_install.exe / {app} / scripts / convert_to_milimerter.pl < prev    next >
Perl Script  |  2012-09-10  |  1KB  |  43 lines

  1. #! /usr/bin/perl
  2.  
  3. #  NCâfü[â^Æåé╠ÉöÆlé╔żÉöô_é¬é┬éóé─éóé╚éóÅΩìçüA        #
  4. #  1/1000ö{é╡é╜Ælé╔ò╧è╖é╡é─żÉöô_é≡òtë┴é╖éΘâXâNâèâvâg  #
  5. #  æ╬Å█é╠âAâhâîâX(É▌ÆΦë┬ö\)é╠îπé╠ÉöÆlé¬æ╬Å█é╞é╚éΘ      #
  6. #  ex. X500Y80Z30. -> X0.5Y0.08Z30.                    #
  7.  
  8. ########################################################
  9. # æ╬Å█é╞é╖éΘâAâhâîâXé≡ÿAæ▒é┼ïLÅqé╡é─é¡é╛é│éó
  10. #ex. XYZIJKRCUVW
  11. $TARGET_ADDRESS = 'XYZIJKRCUVW';
  12. ########################################################
  13.  
  14.  
  15. $pre_file= $ARGV[0];
  16. $out_file= $ARGV[1];
  17. open(IN,$pre_file);
  18. open(OUT,">$out_file");
  19.  
  20. while(<IN>){
  21.     
  22.     $new_line= "";
  23.     $comment_line = "";
  24.     
  25.     while(/\(.*\)\s*/){
  26.         $comment_line = $comment_line . $&;
  27.         $_ = $`.$';
  28.     }
  29.     
  30.     while(/([$TARGET_ADDRESS])([\-\d\.]+)/){
  31.         ($pre_line,$char,$num,$_)= ($`,$1,$2,$');
  32.         
  33.         if($num !~ /\./){
  34.             $num= int($num*1000)/1000000;
  35.             if($num !~ /\./ and $num != 0){ $num= $num."\."; }
  36.         }
  37.         $new_line= $new_line.$pre_line.$char.$num;
  38.     }
  39.     
  40.     $_= $new_line.$_.$comment_line;
  41.     
  42.     print OUT;
  43. }